package screens;

import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.Font;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;

import javax.swing.BoxLayout;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JSeparator;

import main.Fonts;
import main.UserInterface;

public class Lesson4 extends JPanel implements MouseListener {
	
	private JLabel label;
	private JButton back;
	private JButton next;

	public Lesson4() {
		
		setPreferredSize(new Dimension(800, 600));
		setLayout(new FlowLayout());
		
		label = new JLabel("<html><center><b>Lesson 4: Sensors</b><br /><br />"+
				"I have 12 sensors that give me information about obstacles! " +
				"I have 4 sonar sensors that can detect objects at distance from 15cm to 6.45m and " +
				"8 IR sensors that can detect objects at distance from 10 to 80cm.<br /><br />" +
				"To display sensor readings on the map press sensor display that is located " +
				"at the bottom right corner. Now just select sensors that you want to observe " +
				"(4 far ones are sonar sensors, 8 close ones are IR sensors). The readings from " +
				"active sensors will be displayed on the map as a line to the closest obstacle (or if there is " +
				"none just a maximum sensing distance).<br /><br />" +
				"Readings from sonar sensors are displayed directly on the map. Readings from " +
				"IR sensors are displayed on the sensor display." +
				"<br /><br />" +
				"Try it out and click the help button to learn more!</center></html>", JLabel.CENTER);
		label.setFont(Fonts.default_font(22));
		label.setPreferredSize(new Dimension(800, 500));
		
		back = new JButton("BACK TO LESSONS");
		back.setPreferredSize(new Dimension(400, 100));
		back.setFont(Fonts.default_font(36));
		next = new JButton("TRY IT OUT");
		next.setPreferredSize(new Dimension(400, 100));
		next.setFont(Fonts.default_font(36));
		
		JPanel buttons = new JPanel();
		buttons.setLayout(new FlowLayout());
		
		buttons.add(back);		
		buttons.add(next);
		
		add(label);
		add(buttons);
		
        back.addMouseListener(this);
        next.addMouseListener(this);
	}
	
	public JPanel getContentPane() {
		return this;
	}

	@Override
	public void mouseClicked(MouseEvent e) {
		if (e.getSource().equals(back)) {
			UserInterface.setContentPane(UserInterface.demo);
		} else {
			UserInterface.setContentPane(UserInterface.simulatorPanel);
		}
	}

	@Override
	public void mouseEntered(MouseEvent e) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void mouseExited(MouseEvent e) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void mousePressed(MouseEvent e) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void mouseReleased(MouseEvent e) {
		// TODO Auto-generated method stub
		
	}
}
